#!/bin/bash

# read data from users and make them option to recheck if provided data are correct

echo -n "Enter your name: "
read NAME
echo -n "Enter your age: "
read AGE
echo -n "Enter your department: "
read DEP

echo "You are enterd following: "
echo "Name:         $NAME"
echo "Age:          $AGE"
echo "Department:   $DEP"

CHECK=0
while [ $CHECK -eq 0 ]
do

echo -n "Is that correct? [Y/N]"
read ANSWER

case "$ANSWER" in
    "Y"|"y" )
        echo "Name:         $NAME" >> empl.txt
        echo "Age:          $AGE" >> empl.txt
        echo "Department:   $DEP" >> empl.txt
        echo "=======================" >> empl.txt
        echo "Your data were saved into employee file"
        CHECK=1
        ;;

    N|n )
        echo "Nothing was saved, run the script again if you want to add data to employee file"
        CHECK=1
        ;;

    * )
        echo "Wrong answer provided"
        ;;
esac
done